import localForage from 'localforage'

const test1 = async () => {
  const db = await localForage.createInstance({
    name: 'test1',
    storeName: 'test1',
    size: 1024 * 1024 * 1024
    // driver: localForage.INDEXEDDB
  })
  await db.setItem('test1', 'test1')
  const res = await db.getItem('test1')
  console.log(res)
}

const test2 = async () => {
  localForage.config({
    name: 'test2',
    storeName: 'test2',
    size: 1024 * 1024 * 1024
    // driver: localForage.INDEXEDDB
  })
  let list = []

  for (let i = 0; i < 10000; i++) {
    list.push({
      addTime: 1722764152590,
      areaName: '四川省 成都市',
      avatar: 'ycc011.jpg',
      contactUserId: 'B1FF768BC6D1B001BCAE4362F202EEB9',
      contactUserSweetCircleId: '9krceIEDz6',
      friendsCode: 1,
      joinType: 1,
      nickName: '测试10',
      noteName: '',
      personalSignature: '不忘初心 牢记使命',
      sex: 0,
      status: 1,
      sweetCircleAuth: 1,
      sweetCircleStatusA: 0,
      sweetCircleStatusB: 0,
      userId: '1629A0960C9441BC96F2EB6852224E7E'
    })
  }

  await localForage.setItem('test2', list)
}

const test3 = async () => {
  localForage.config({
    // name: 'test3',
    // storeName: 'test3',
    size: 1024 * 1024 * 1024,
    driver: localForage.LOCALSTORAGE
  })
  localForage.setItem('key', 'value')
  localForage.getItem('key').then(function (value) {
    console.log("111111 ",value)
  })
}

export default {
  test1,
  test2,
  test3
}


//
// import LocalForageTool from "#/utils/localForageTool";
//
//
// LocalForageTool.test1()
// LocalForageTool.test2()
// LocalForageTool.test3()
